package com.ss.ttm.a;

import android.app.ActivityManager;
import android.content.Context;
import android.os.Environment;
import android.os.StatFs;

import java.io.BufferedReader;
import java.io.FileReader;

public final class c {
    private static long[] a;
    private static long b;

    static {
        c.b = 0;
    }

    public static long a(Context arg4) {
        Object v0 = arg4.getSystemService(Context.ACTIVITY_SERVICE);
        ActivityManager.MemoryInfo v1 = new ActivityManager.MemoryInfo();
        ((ActivityManager) v0).getMemoryInfo(v1);
        return v1.availMem / 1024;
    }

    public static long[] a() {
        if (c.a == null) {
            long[] v0 = new long[2];
            if (c.b == 0) {
                StatFs v3 = new StatFs(Environment.getDataDirectory().getPath());
                c.b = (((long) v3.getBlockCount())) * (((long) v3.getBlockSize()));
            }

            v0[0] = c.b;
            StatFs v2 = new StatFs(Environment.getDataDirectory().getPath());
            v0[1] = (((long) v2.getAvailableBlocks())) * (((long) v2.getBlockSize()));
            c.a = v0;
        }

        return c.a;
    }

    public static long b() {
        BufferedReader v2 = null;
        String v1 = "/proc/meminfo";
        try {
            v2 = new BufferedReader(new FileReader(v1), 8);
            v1 = v2.readLine();
            if (v1 == null) {
                return 0L;
            }
            return ((long) Integer.parseInt(v1.substring(v1.indexOf(58) + 1, v1.indexOf(107)).trim()));
        } catch (Throwable throwable) {

        } finally {
            try {
                v2.close();
            } catch (Exception e) {

            }
        }
        return 0L;

    }
}

